home *** CD-ROM | disk | FTP | other *** search
- import java.applet.Applet;
- import java.awt.Button;
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Container;
- import java.awt.FlowLayout;
- import java.awt.GridLayout;
- import java.awt.Label;
- import java.awt.Panel;
- import java.awt.TextArea;
- import java.awt.TextField;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.io.BufferedReader;
- import java.io.DataOutputStream;
- import java.io.InputStreamReader;
- import java.net.Socket;
- import java.net.URL;
- import java.util.EventObject;
-
- public class EmailSender extends Applet implements ActionListener {
- // $FF: renamed from: wi int
- private int field_0;
- // $FF: renamed from: he int
- private int field_1;
- private String fond;
- private String mailServer;
- private TextField tname;
- private TextField tmail;
- private TextField tsubject;
- // $FF: renamed from: ta java.awt.TextArea
- private TextArea field_2;
- // $FF: renamed from: tt java.awt.TextArea
- private TextArea field_3;
- private String text1;
- private String text2;
- private String text3;
- private String text4;
- private String text5;
-
- public String getAppletInfo() {
- return "Name: EmailSender\r\nAuthor: Taiji Software\r\n";
- }
-
- public void register() {
- try {
- URL u = new URL("http://www.taijisoftware.com");
- ((Applet)this).getAppletContext().showDocument(u, "_blank");
- ((Applet)this).stop();
- } catch (Exception e) {
- System.out.println(e);
- ((Applet)this).stop();
- }
- }
-
- public void init() {
- String codeBase = null;
-
- try {
- codeBase = (new URL(((Applet)this).getCodeBase().toString())).getHost();
- System.out.println("Copyright 1999, 2001 Taiji Software(tm)\nYour domain name is : " + codeBase);
- codeBase = codeBase.toUpperCase();
- } catch (Exception var9) {
- }
-
- if (!((Applet)this).getCodeBase().toString().toUpperCase().startsWith("FILE") || ((Applet)this).getParameter("debug") != null) {
- String regCode = ((Applet)this).getParameter("registration_code");
- if (regCode == null) {
- regCode = ((Applet)this).getParameter("reg_domain");
- if (regCode == null) {
- this.register();
- } else {
- if (regCode.length() == codeBase.length() + 4 && !codeBase.startsWith("WWW.")) {
- codeBase = "WWW." + codeBase;
- } else if (regCode.length() == codeBase.length() - 4 && codeBase.startsWith("WWW.")) {
- codeBase = codeBase.substring(4);
- }
-
- char[] chars = new char[codeBase.length()];
- codeBase.getChars(0, codeBase.length(), chars, 0);
- String key = new String("haricot");
- char[] chars2 = new char[key.length()];
- key.getChars(0, key.length(), chars2, 0);
-
- for(int i = 0; i < codeBase.length(); ++i) {
- int j;
- if (i >= key.length()) {
- j = i - key.length() * (i / key.length());
- } else {
- j = i;
- }
-
- chars[i] += chars2[j];
- chars[i] = (char)(chars[i] - chars[i] / 26 * 26 + 97);
- }
-
- String res = new String(chars);
- if (!res.equalsIgnoreCase(regCode)) {
- this.register();
- }
- }
- } else if (!regCode.equals("settevercsedegnamiaj") && !regCode.equals("8078")) {
- this.register();
- }
- }
-
- this.getParameters();
- ((Container)this).setLayout(new GridLayout(3, 1));
- Panel p1 = new Panel();
- Panel p2 = new Panel();
- Panel p3 = new Panel();
- ((Container)this).add(p1);
- ((Container)this).add(p2);
- ((Container)this).add(p3);
- ((Container)p1).setLayout(new GridLayout(4, 2));
- ((Container)p2).setLayout(new FlowLayout());
- ((Container)p1).add(new Label(this.text1));
- this.tname = new TextField();
- ((Container)p1).add(this.tname);
- ((Container)p1).add(new Label(this.text2));
- this.tmail = new TextField();
- ((Container)p1).add(this.tmail);
- ((Container)p1).add(new Label(this.text3));
- this.tsubject = new TextField();
- ((Container)p1).add(this.tsubject);
- this.field_3 = new TextArea(this.text4, 6, 50);
- ((Container)p2).add(this.field_3);
- ((Container)p2).add(new Label(" "));
- Button b = new Button(this.text5);
- b.addActionListener(this);
- ((Component)b).setSize(40, 20);
- ((Container)p2).add(b);
- this.field_2 = new TextArea("", 4, 60);
- this.field_2.setEditable(false);
- ((Container)p3).add(this.field_2);
- }
-
- public void getParameters() {
- this.field_0 = ((Component)this).getSize().width;
- this.field_1 = ((Component)this).getSize().height;
- this.mailServer = ((Applet)this).getParameter("mail_server");
- if (this.mailServer == null) {
- if (((Applet)this).getCodeBase().getProtocol().equals("file")) {
- this.mailServer = "localhost";
- } else {
- this.mailServer = ((Applet)this).getCodeBase().getHost();
- }
- }
-
- this.text1 = ((Applet)this).getParameter("text1");
- if (this.text1 == null) {
- this.text1 = "Mail from :";
- }
-
- this.text2 = ((Applet)this).getParameter("text2");
- if (this.text2 == null) {
- this.text2 = "Mail to :";
- }
-
- this.text3 = ((Applet)this).getParameter("text3");
- if (this.text3 == null) {
- this.text3 = "Subject :";
- }
-
- this.text4 = ((Applet)this).getParameter("text4");
- if (this.text4 == null) {
- this.text4 = "your message...";
- }
-
- this.text5 = ((Applet)this).getParameter("text5");
- if (this.text5 == null) {
- this.text5 = "Send message";
- }
-
- ((Component)this).setBackground(this.getColor("background_color"));
- }
-
- public Color getColor(String param) {
- String s = ((Applet)this).getParameter(param);
- if (s != null) {
- if (s.substring(0, 1).equals("#")) {
- s = s.substring(1);
- int i = Integer.parseInt(s, 16);
- return new Color(i);
- } else {
- return null;
- }
- } else {
- return null;
- }
- }
-
- public void actionPerformed(ActionEvent evt) {
- if (((EventObject)evt).getSource() instanceof Button) {
- String from = this.tname.getText();
- if (from.length() == 0) {
- this.field_2.append("You must fill out the \"" + this.text1 + "\" field.\n");
- return;
- }
-
- String recipient = this.tmail.getText();
- if (recipient.length() == 0) {
- this.field_2.append("You must fill out the \"" + this.text2 + "\" field.\n");
- return;
- }
-
- this.send(from, recipient);
- }
-
- }
-
- public void send(String from, String recipient) {
- try {
- System.out.println("Trying to connect to " + this.mailServer + " on port 25...");
- this.field_2.append("Trying to connect to " + this.mailServer + " on port 25...\n");
- Socket sock = new Socket(this.mailServer, 25);
- System.out.println("Connected !");
- this.field_2.append("Connected !\n");
- DataOutputStream out = new DataOutputStream(sock.getOutputStream());
- System.out.println("out ok");
- BufferedReader in = new BufferedReader(new InputStreamReader(sock.getInputStream()));
- System.out.println("in ok");
- this.isOk(in);
- out.writeBytes("HELO EmailSender.com\r\n");
- this.isOk(in);
- out.writeBytes("MAIL FROM:" + from + "\r\n");
- this.isOk(in);
- out.writeBytes("RCPT TO:<" + recipient + ">\r\n");
- this.isOk(in);
- out.writeBytes("DATA\r\n");
- this.isOk(in);
- out.writeBytes("Subject: " + this.tsubject.getText() + "\n\n" + this.field_3.getText() + "\r\n.\r\nQUIT\r\n");
- if (this.isOk(in)) {
- this.field_2.append("Your email has been sent !\n");
- }
-
- sock.close();
- } catch (Exception e) {
- System.err.println(e);
- this.field_2.append("Error !!: " + ((Throwable)e).toString() + "\n");
- }
- }
-
- public boolean isOk(BufferedReader in) {
- String s = "";
-
- try {
- s = in.readLine();
- System.out.println(s);
- } catch (Exception var3) {
- ((Applet)this).stop();
- return false;
- }
-
- if (!s.startsWith("4") && !s.startsWith("5")) {
- return true;
- } else {
- this.field_2.append("Error: " + s + "\n");
- ((Applet)this).stop();
- return false;
- }
- }
- }
-